package com.ailk.cuc.autotestbg.common.utils;

import java.io.StringReader;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.apache.commons.logging.Log;

import com.ibatis.sqlmap.engine.type.StringTypeHandler;

public class IbatisLongStringHandler extends StringTypeHandler {
	
	private static Log logger = LogUtils.getLogger(IbatisLongStringHandler.class.getName());
	@Override
	public void setParameter(PreparedStatement ps, int i, Object parameter,
			String jdbcType) throws SQLException {
		String source = (String)parameter;
		logger.debug("source.length : "+source.length());
		if(source.length()<1000){
			super.setParameter(ps, i, parameter, jdbcType);
		}else{
			ps.setCharacterStream(i, new StringReader(source), source.length());
		}
	}
}
